package com.atguigu.guli.service.ucenter.controller.api;

import com.atguigu.guli.service.base.exception.GuliException;
import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.base.result.ResultCodeEnum;
import com.atguigu.guli.service.ucenter.service.WXloginService;
import com.atguigu.guli.service.ucenter.util.UcenterProperties;
import com.atguigu.guli.service.util.utils.HttpClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.UUID;

@Controller

@RequestMapping("api/ucenter/wx")
public class ApiWXcontroller {
    @Autowired
    UcenterProperties ucenterProperties;
    //用户点击时，向浏览器发起重定向请求，向微信的授权服务器请求授权信息，在页面显示授权请求的二维码
    @Autowired
    WXloginService wXloginService;

    @GetMapping("login")
    public String loginWX(HttpSession session){
        return wXloginService.login(session);
    }

    @GetMapping("callback")
    public String callback(@RequestParam String code , @RequestParam String state, HttpSession session){
        return  wXloginService.callback(code,state,session);
    }

}
